//
//  WJLabel.m
//  XJMCustomer
//
//  Created by 洗脚么_one on 2018/1/16.
//  Copyright © 2018年 Mr.hu. All rights reserved.
//

#import "WJLabel.h"

@interface WJLabel ()

@end

@implementation WJLabel
@synthesize textAlignmentwj = textAlignmentwj_;

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.textAlignment = LQTextAlignmentMiddle;
    }
    return self;
}

-(void)setTextAlignmentwj:(LQTextAlignment)textAlignmentwj {
    textAlignmentwj_ = textAlignmentwj;
    [self setNeedsDisplay];
}

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
    CGRect textRect = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];
    switch (self.textAlignment) {
        case LQTextAlignmentTop:
            textRect.origin.y = bounds.origin.y;
            break;
        case LQTextAlignmentBottom:
            textRect.origin.y = bounds.origin.y + bounds.size.height - textRect.size.height;
            break;
        case LQTextAlignmentMiddle:
            
        default:
            textRect.origin.y = bounds.origin.y + (bounds.size.height - textRect.size.height) / 2.0;
    }
    return textRect;
}

-(void)drawTextInRect:(CGRect)requestedRect {
    CGRect actualRect = [self textRectForBounds:requestedRect limitedToNumberOfLines:self.numberOfLines];
    [super drawTextInRect:actualRect];
}

@end
